<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>switch打印星期几0为星期日1-6分别对应星期一到星期六</title>
</head>
<body>
    <script>
        var num = 5;
        // num = Number(num);
        // if (!isNaN(num)){
        if (typeof(num)==="number"){
            switch(num){
                case 0:
                    console.log("星期日");
                    break;
                case 1:
                    console.log("星期一");
                    break;
                case 2:
                    console.log("星期二");
                    break;    
                case 3:
                    console.log("星期三");
                    break;
                case 4:
                    console.log("星期四");
                    break;
                case 5:
                    console.log("星期五");
                    break;
                case 6:
                    console.log("星期六");
                    break;
                default:
                    console.log("请输入0-6之间的数字");
            }
        }

        var day = 3;
        var weekDay = ["日","一","二","三","四","五","六"];
        console.log("星期" + weekDay[day]);

    </script>
</body>
</html>